<html><!-- InstanceBegin template="/Templates/_Admin_Template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>TCedit 测试用例编写工具 - 角色管理</title>
<!-- InstanceEndEditable -->
<link rel="shortcut icon" href="favicon.ico">
<link href="/css/common.css" rel="stylesheet" type="text/css">
<script src="/js/prototype.js"></script>
<script src="/js/common.js"></script>
<script>
function doAction(action){
  if (action == "create") {
    document.formData.action = "/admin/role.jspx?action=create&page=${page}";
  } else if (action == "update") {
    document.formData.action = "/admin/role.jspx?action=update&id=${role.id}&page=${page}";
  } else if (action == "delete") {
    if(confirm("是否确定要删除？")) {
      document.formData.action = "/admin/role.jspx?action=delete&id=${role.id}&page=${page}";
      document.formData.submit();
    }
  }
}

window.onload = function() {
  setChkPermission();
}

function setChkPermission() {
	var words = $F("urlPermissionStr").split('|');
	for(var i=0; i<words.length; i++) {
		if (words[i]!="") {
			for(var j=0; j<document.all.length; j++) {
				if(document.all(j).type=='checkbox' && document.all(j).value==words[i] && document.all(j).id=='urlPermission') {
					document.all(j).checked = true;
				}
			}
		}
	}

	var words = $F("methodPermissionStr").split('|');
	for(var i=0; i<words.length; i++) {
		if (words[i]!="") {
			for(var j=0; j<document.all.length; j++) {
				if(document.all(j).type=='checkbox' && document.all(j).value==words[i] && document.all(j).id=='methodPermission') {
					document.all(j).checked = true;
				}
			}
		}
	}
}
</script>
<script>
function checkForm(){
	if($F("name")==""){
		alert("请输入“角色名称”！");
		return false;
	}

	if($F("describing")==""){
		alert("请输入“角色描述”！");
		return false;
	}

	var urlPermissionTxt = "";
	for(var i=0; i<document.all.length; i++) {
		if(document.all(i).type=='checkbox' && document.all(i).checked==true && document.all(i).id=='urlPermission') {
			urlPermissionTxt = urlPermissionTxt + document.all(i).value + "|";
		}
	}
	$("urlPermissionStr").value = urlPermissionTxt;

	var methodPermissionTxt = "";
	for(var i=0; i<document.all.length; i++) {
		if(document.all(i).type=='checkbox' && document.all(i).checked==true && document.all(i).id=='methodPermission') {
			methodPermissionTxt = methodPermissionTxt + document.all(i).value + "|";
		}
	}
	$("methodPermissionStr").value = methodPermissionTxt;

	return true;
}
</script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>

<body>
<!-- InstanceBeginEditable name="MainContent" -->
<table width="99%" align="center" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%" valign="top">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td colspan="4" bgcolor="#dedeef"><b>角色信息</b></td>
        </tr>
        <tr>
          <td></td>
          <td>
            #if($error)
              <font color="#FF0000">$error</font>
            #end
          </td>
        </tr>
        <form action="" method="post" enctype="multipart/form-data" name="formData" id="formData" onSubmit="return checkForm()">
        <input name="urlPermissionStr" type="hidden" id="urlPermissionStr" value="$!{role.urlPermissionStr}" />
        <input name="methodPermissionStr" type="hidden" id="methodPermissionStr" value="$!{role.methodPermissionStr}" />
        <tr>
          <td width="15%" align="right">角色名称：</td>
          <td width="85%"><input name="name" type="text" class="text" id="name" maxlength="20" value="$!{role.name}" /> <b><font color="#FF0000">*</font></b> 角色名必须以 ROLE_ 开头且只能由英文字母和数字构成，例如：ROLE_ADMIN</td>
        </tr>
        <tr>
          <td align="right">角色描述：</td>
          <td><input name="describing" type="text" class="text" id="describing" style="width:250px;" maxlength="30" value="$!{role.describing}" /> <b><font color="#FF0000">*</font></td>
        </tr>
        <tr>
          <td align="right"></td>
          <td><input name="bonding" type="checkbox" id="bonding" value="true" #if($role.bonding) checked #end>邦定到产品</input></td>
        </tr>
        <tr>
          <td align="right">权限设置：</td>
          <td>（将鼠标停留在权限描述上可以显示该权限所控制的URL地址）</td>
        </tr>
        <tr>
          <td></td>
          <td>
            <table border="0">
            #foreach($permission in $permissions)
              <tr>
                <td>$!{permission.attributeValue("desc")}</td>
                <td>
                #foreach($urlPermission in $permission.elements("urlPermission"))
                  <input id="urlPermission" type="checkbox" value="$!{urlPermission.attributeValue('value')}" />
                  <a Title="url: $!{urlPermission.attributeValue('value')}">$!{urlPermission.attributeValue("desc")}</a></br>
                #end
                #foreach($methodPermission in $permission.elements("methodPermission"))
                  <input id="methodPermission" type="checkbox" value="$!{methodPermission.attributeValue('value')}" />
                  <a Title="method: $!{methodPermission.attributeValue('value')}">$!{methodPermission.attributeValue("desc")}</a></br>
                #end
                </td>
              </tr>
              <tr>
                <td colspan="2"><hr></hr></td>
              </tr>
            #end
            </table>
          </td>
        </tr>
        <tr>
          <td></td>
          <td>
            #if($action=="" || $action=="create")
              <input name="SubmitCreate" type="submit" class="button" id="SubmitCreate" value="新增" onClick="doAction('create')" />
            #else
              #if (!($action=="delete"))
                <input name="SubmitUpdate" type="submit" class="button" id="SubmitUpdate" value="修改" onClick="doAction('update')" />
              #end
              <input name="SubmitDelete" type="button" class="button" id="SubmitDelete" value="删除" onClick="doAction('delete')" />
            #end
          </td>
          <td></td>
          <td></td>
        </tr>
        </form>
      </table>
    </td>
  </tr>
</table>
<!-- InstanceEndEditable -->
</body>
<!-- InstanceEnd --></html>